home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Directorty Opus 5 - Magellan 2
/
Opus 5 - Magellan 2.iso
/
Extras
/
Dopus-MidiPlay
/
Playmidi.dopus5
next >
Wrap
Text File
|
1998-04-12
|
3KB
|
129 lines
/* Arexx Script To play Midi Files for DOPUS 5
(C)1998 Raistlin
Version 1.1
Now correctly handle names with spaces ....
If you like this stuff, please send me a mail (elrond@club-internet.fr)
Usage : DOpus5:ARexx/Playmidi.dopus5 {f} {Qp}
run asynchronously
*/
parse arg '"'file'"' portname .
if portname='' then
portname = 'DOPUS.1'
address DOPUS.1
options results
if ~show('l','rexxsupport.library') then
call addlib('rexxsupport.library',0,-30)
lister query source
if rc>0 then do
dopus request '"No source selected." OK'
exit
end
parse var result handle .
lister set handle busy on
cuthere=lastpos('/',file)
if cuthere=0 then
cuthere=pos(':',file)
name=""substr(file,cuthere+1)""
lister set handle newprogress info bar abort
lister set handle newprogress title 'Playing 'name' ...'
lister set handle newprogress info 'Loading Instruments ...'
address command 'GM:'
address command 'Run >T:gmplay <NIL: gm:GMPLAY <NIL: >PIPE:gm-output "'file'"'
open('temp','T:gmplay','r')
process = readln('temp')
parse var process '[CLI ' process ']'
close('temp')
call delete('T:gmplay')
buffer=''
open('gm','PIPE:gm-output','r')
timer=0
measure=0
percent=0
timerbak=-1
ended=0
do until ended > 0
buffer=buffer||readch('gm',15)
new=verify(buffer,'%','m')
loading=verify(buffer,'(','m')
ended=pos('Finished',buffer)
/* Gestion des erreurs ********************************/
if pos('Unable to initialize GM',buffer) >0 then do
address command 'Break' process 'C'
lister clear handle progress
lister set handle busy off
call close('gm')
lister request handle '"Unable to initialize GM" OK'
exit
end
if pos('t open audio driver',buffer) >0 then do
address command 'Break' process 'C'
lister clear handle progress
lister set handle busy off
call close('gm')
lister request handle '"Cannot open audio driver" OK'
exit
end
/******************************************************/
lister query handle abort
if result then do
address command 'Break' process 'C'
lister clear handle progress
lister set handle busy off
call close('gm')
exit
end
if loading >0 then do
line=left(buffer,loading-1)
buffer=substr(buffer,loading+1)
samplepos=lastpos('Loading',line)
sample=substr(line,samplepos,loading-samplepos)
lister set handle newprogress info sample
end
else
if new >0 then do /* check for new line */
line=left(buffer,new-1)
buffer=substr(buffer,new+1)
pos0=pos('Time',line)
pos1=pos('Meas',line)
pos2=pos('Perc',line)
if pos0 + pos1 + pos2 ~= 0 then do
timer = substr(line,pos0+5,5)
measure = substr(line,pos1+8,pos2-pos1-8)
percent = substr(line,pos2+11,3)
if timer ~= timerbak then do
lister set handle newprogress info 'Playing measure:'measure' Time: 'timer
lister set handle newprogress bar 100 percent
timerbak=timer
end
end
end
end
call close('gm')
lister clear handle progress
lister set handle busy off